﻿/**
 * @file FITKNastranAdaptorCase.h
 * @author zhourp (zhourunping@diso.cn)
 * @brief the class of adaptor for case
 * @date 2024-11-14
 */
#ifndef FITKABAQUSADAPTORCASE_H
#define FITKABAQUSADAPTORCASE_H

#include "FITKNastranAbstractAdaptor.h"
#include "FITKNastranAdaptorMAT1.h"
#include "FITKNastranAdaptorPSHELL.h"
#include "FITKNastranAdaptorPart.h"

#include "FITK_Component/FITKAbaqusData/FITKDataCase.h"
#include "FITK_Interface/FITKInterfaceModel/FITKComponentManager.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKSectionAssign.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterial.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialBehavior.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialDamping.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialDensity.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialElastic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialExpansion.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMeshPartVTK.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionBeam.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionShellHomogeneous.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITK_Kernel/FITKAppFramework/FITKMessage.h"

namespace Nastran
{
/**
 * @brief the class of adaptor for case
 * 
 * @author: zhourp (zhourunping@diso.cn)
 * @date: 2024-11-14
 */
class FITKNastranBDFIOAPI FITKNastranAdaptorCase : public FITKNastranAbstractAdaptor
{
  public:
    explicit FITKNastranAdaptorCase();
    virtual ~FITKNastranAdaptorCase();

    /**
     * @brief 适配器读取
     * @return 状态 true成功， false失败
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    bool adaptR() override;

    /**
     * @brief Assigns case data to the FITKNastranAdaptorCase.
     *
     * This function is responsible for setting the case data
     * for the FITKNastranAdaptorCase from the AbaqusData structure.
     *
     * @param[in] caseData Pointer to the Abaqus data case.
     *
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    void setCaseData(AbaqusData::FITKDataCase *caseData);

    /**
     * @brief Check if a line corresponds to a Nastran part line.
     * @param[in] line The line to be checked.
     * @return True if the line is a Nastran part line, false otherwise.
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    bool isPartLine(QString line);

  private:
    /**
     * @brief 从缓存中读取Nastran模型的部分数据并更新网格。
     *
     * @param[in,out] mesh 指向Abaqus网格数据的指针。
     * @param[in] cache 包含文件内容的缓存队列。
     * @return true 如果读取和更新操作成功，否则返回false。
     *
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    bool readMAT1(QQueue<QString> cache);

    /**
     * @brief Reads PSHELL data from a cache and adapts it using the PSHELL adaptor.
     * @param cache [i] QQueue of QStrings containing the file content cache.
     * @return True if the adaptation is successful, false otherwise.
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    bool readPSHELL(QQueue<QString> cache);

    /**
     * @brief Transfers Nastran data to Abaqus mesh
     *
     * This function imports a part from Nastran data into the specified Abaqus mesh.
     * It utilizes a part adaptor to facilitate the data transfer process.
     *
     * @param[in,out] mesh Pointer to the Abaqus part mesh
     * @param[in] cache Queue of QStrings containing file content cache
     * @return bool True if the part is successfully read, false otherwise
     *
     * @author zhourp(zhourunping@diso.cn)
     * @date 2024-11-14
     */
    bool readPart(AbaqusData::FITKAbaqusPart *mesh, QQueue<QString> cache);

    /**
     * @brief 算例数据
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    AbaqusData::FITKDataCase *_caseData{};

    /**
     * @brief material adaptor ptr
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    FITKNastranAdaptorMAT1 *_mat1Adaptor{};

    /**
     * @brief pshell adaptor ptr
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    FITKNastranAdaptorPSHELL *_pshellAdaptor{};

    /**
     * @brief part adaptor ptr
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    FITKNastranAdaptorPart *_partAdaptor{};
};

Register2FITKIOAdaptorFactory(BDF, AbaqusData::FITKDataCase, FITKNastranAdaptorCase)
} // namespace Nastran
#endif // FITKABAQUSADAPTORCASE_H
